//
//  DHDetailView.m
//  精品酒店
//
//  Created by DIANGHONG on 2018/5/11.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "DHDetailView.h"
#import "DHHeaderViewCell.h"
NSString *headerViewCellId = @"headerViewCellId";
@interface DHDetailView()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *detailListView;

@end

@implementation DHDetailView

#pragma mark: - setDetailModel
- (void)setDetailModel:(DHDetailModel *)detailModel{
    _detailModel = detailModel;
    
    NSLog(@"%@",detailModel);
    [self.detailListView reloadData];
}
#pragma mark: - 实例化类方法
+ (instancetype)detailViewWithFrame:(CGRect)frame
{
    UINib *nib = [UINib nibWithNibName:@"DHDetailView" bundle:nil];
    DHDetailView *detailView = [nib instantiateWithOwner:nil options:nil][0];
    detailView.frame = frame;
    return detailView;
}


- (void)awakeFromNib{
    [super awakeFromNib];
    
    self.detailListView.dataSource = self;
    self.detailListView.delegate = self;
    self.detailListView.rowHeight = 720;
    [self.detailListView registerNib:[UINib nibWithNibName:@"DHHeaderViewCell" bundle:nil]
              forCellReuseIdentifier:headerViewCellId];
    
    
}
#pragma mark: - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DHHeaderViewCell *cell = [tableView dequeueReusableCellWithIdentifier:headerViewCellId forIndexPath:indexPath];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.model = self.detailModel;
    return cell;
}

#pragma mark: - 导航按钮点击事件
- (IBAction)navigationButtonClick:(id)sender
{
    [self.delegate detailViewDidnavigationButtonClick:self];
}
#pragma mark: - 立即预约按钮点击事件
- (IBAction)immPayButtonClick:(id)sender
{
    NSAssert(self.completUserInfoClick != nil, @"self.completUserInfoClick 不能为nil");
    
    self.completUserInfoClick();
}
#pragma mark: - 咨询按钮点击事件
- (IBAction)serviceButtonClick:(id)sender {
}

@end
